package com.examples.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectionExample {

	public static void main(String[] args) throws ClassNotFoundException,
			SQLException {

		Class.forName("com.mysql.jdbc.Driver");

		Connection connection = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/classicmodels", "root", "root");

		System.out.println(connection.getMetaData().getDatabaseProductName());

		Statement statement = connection.createStatement(
				ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

		ResultSet resultSet = statement.executeQuery("SELECT * from customers");

		 
		 while (resultSet.next()) {

			System.out.println(" Name - " + resultSet.getString(2)
					+ " Number -" + resultSet.getString(1));
			
			if(resultSet.getString(2).equalsIgnoreCase("Signal Gift Stores"))
			{
				resultSet.updateString("customerName", resultSet.getString(2)+" -Updated");
				resultSet.updateRow();
			}
			
			

		} 

	}

	// we need to get the information from results set here

}
